package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],  # Apache 2.0
)

load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "p4types_proto",
    srcs = ["p4/config/v1/p4types.proto"],
    # TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix breaks
    # cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
    # strip_import_prefix = "proto",
)

proto_library(
    name = "p4data_proto",
    srcs = ["p4/v1/p4data.proto"],
    # TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix breaks
    # cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
    # strip_import_prefix = "proto",
)

proto_library(
    name = "p4info_proto",
    srcs = ["p4/config/v1/p4info.proto"],
    deps = [
        ":p4types_proto",
        "@com_google_protobuf//:any_proto",
        "@com_google_protobuf//:descriptor_proto",
    ],
    # TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix breaks
    # cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
    # strip_import_prefix = "proto",
)

proto_library(
    name = "p4runtime_proto",
    srcs = ["p4/v1/p4runtime.proto"],
    deps = [
        ":p4info_proto",
        ":p4data_proto",
        "@com_google_protobuf//:any_proto",
        "@com_google_googleapis//google/rpc:status_proto"
    ],
    # TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix brakes
    # cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
    # strip_import_prefix = "proto",
)

cc_proto_library(
    name = "p4types_cc_proto",
    deps = [":p4types_proto"],
)

cc_proto_library(
    name = "p4info_cc_proto",
    deps = [":p4info_proto"],
)

cc_proto_library(
    name = "p4data_cc_proto",
    deps = [":p4data_proto"],
)

cc_proto_library(
    name = "p4runtime_cc_proto",
    deps = [":p4runtime_proto"],
)

py_proto_library(
    name = "p4types_py_proto",
    deps = [":p4types_proto"],
)

py_proto_library(
    name = "p4info_py_proto",
    deps = [":p4info_proto"],
)

py_proto_library(
    name = "p4data_py_proto",
    deps = [":p4data_proto"],
)

py_proto_library(
    name = "p4runtime_py_proto",
    deps = [":p4runtime_proto"],
)

go_proto_library(
    name = "p4info_go_proto",
    importpath = "github.com/p4lang/p4runtime/go/p4/config/v1",
    protos = [
        ":p4info_proto",
        ":p4types_proto",
    ],
)

go_proto_library(
    name = "p4runtime_go_proto",
    importpath = "github.com/p4lang/p4runtime/go/p4/v1",
    protos = [
        ":p4runtime_proto",
        ":p4data_proto",
    ],
    deps = [
        ":p4info_go_proto",
        "@com_google_googleapis//google/rpc:status_go_proto",
    ],
)


cc_grpc_library(
    name = "p4runtime_cc_grpc",
    grpc_only = True,
    srcs = [":p4runtime_proto"],
    deps = [":p4runtime_cc_proto"],
)

py_grpc_library(
    name = "p4runtime_py_grpc",
    srcs = [":p4runtime_proto"],
    deps = [":p4runtime_py_proto"],
)
